<div class="no-js">
    <h2>JavaScript is off</h2>
    <p>Encryption requires that JavaScript be on. It’s <a href="https://notabug.org/apiote/website">Software Libre.</a></p>
</div>
<div class="contact-form">
    <span class="label">Reply-to email address</span>
    <input type="email" id="reply-to">

    <span class="label">Message</span>
    <textarea id="message" required rows="12"></textarea>
    <div class="validate validate-message">
        <p><span class="error">error:</span> Message cannot be empty</p>
    </div>

    <span class="label anti-bots">leave blank</span>
    <input type="text" id="hidden" class="anti-bots">

    <button><i class="material-icons">send</i></button>

    <div id="fail">
        <p><span class="error">error:</span> The message wasn’t sent</p>
    </div>

    <hr>
    <p class="note">While email address is not required, mind that I won’t be able to respond if You don’t provide it</p>
    <p class="note">All of the fields are encrypted locally with my public key so only whoever holds my private key (hopefully, that’s me) will be able to decrypt Your email address, and the message.</p>
</div>
<div class="sent">
    <h1>Thank You!</h1>
    <h2>Your message has been sent</h2>
</div>


<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt GNU-AGPL-v3.0
    $(function() {
        $('#message').keypress(function() {
            $('.validate-message').css('display', 'none');
        });
        $('button').click(function() {
            let email = $('#reply-to').val();
            let message = $('#message').val();
            let botDetection = $('#hidden').val();
            if (botDetection != '') {
                return false;
            }
            if (message == '') {
                $('.validate-message').css('display', 'block');
                return false;
            }
            var msg = `email: ${email}\n\nmessage:\n${message})`;

            let publicKeyString = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
            "\n" +
            "mQENBFambncBCAC6+jFaReHRLmMSVk5nKBDsAeJIxzbcQQRxTHHGLyxu0Wr17GEO\n" +
            "f9GI4nnN2qheMSaxswU9CtTCa0noKQU7mt6J+yUQFpzZteRbQ/7WWmtRSwDmr3kq\n" +
            "/7rMIwIe7aCWzNL6bZAsWfwOnAgx1mm5Ugwm3hBohDJZGnAulFINQMJoP/fH2Ym7\n" +
            "n2AFka+zTFE/NGnpJTgd6Hu3XS9lbeGBoY4/7K8cjIYrXuaIMeOk/hsIWGKtKqE1\n" +
            "uYrvoVEI731c/KI7sh3QZjxFVXgOdO6H+Sp+Y5KLkT5OgIrVgblrwkUqBhVhvWeq\n" +
            "N5jAQErPGcocKRALjBbSIPk6qh3O4k4+BSKDABEBAAG0O2FkYW0ucGlvdGVyZWtA\n" +
            "cHJvdG9ubWFpbC5jb20gPGFkYW0ucGlvdGVyZWtAcHJvdG9ubWFpbC5jb20+iQE1\n" +
            "BBABCAApBQJY3pUhBgsJBwgDAgkQJELid3bgpXgEFQgKAgMWAgECGQECGwMCHgEA\n" +
            "AMfFCACixW1beJdUcVOoUEZJ1xy3PN+LXU+l9nRw8lOfSs1zN7hocAPoW0LafMRQ\n" +
            "cO8M1d8MYgU/EuG2Z8c974GZwJYhUWWshvudPk64bot6Ts9+w42q/izvOthN4kay\n" +
            "MCCTo4SOD7dUESwupIxkWRjnbRg7OpHOy9xvuldMGsGRn1qgAL0rn72bdxKor0TY\n" +
            "XRNa48d8pO+TVKPV4tXnLB5VuU3zyHsIfNzoN7F5VdhTaNJU1Cc+Fs79PGDkpwTU\n" +
            "atwhIOijHeLxGR1Kye9xtJ576DfoVEwud35aAQecRslnhumdx1v9Fr0dwGGezoiS\n" +
            "r/xoq4NT0zDbGLZV0Wv86rGbxrrziQIzBBMBCAAdFiEEe/v5UGjIsgYWkz5dNL7a\n" +
            "odYiuJEFAlriXl8ACgkQNL7aodYiuJE2mQ//dtHZ6qEGaTDK89Qo+X0nPz2sE43h\n" +
            "NQ1kgNipe6/sDl1xi1MGhfJtxQkxOVkqggq0mRJe35JL98V0naln9KVQ+21RoVNX\n" +
            "P9Epw9V9Tgv4qA1C+5eLVR7DnqhH8iaI6Xb5CTbA5lsDrnSBjpoZLA8Vm980Hb21\n" +
            "oYWibTwPzm4Xa9cTunm/LS8VDYqsdQieZBr6ZhfDyDwSBUXXssU4WSoak5eRQ4Xz\n" +
            "KPiurAfOTtmqfpAazjtLtOqLOdPY2PGImSxxNfSVnWlphhWx9QKCgm2XHsGFMiHW\n" +
            "zFadw+49rguMK9H8a15nap9ECHtSU1HJ+rV/S7DBt+lwdb3uI9ma2fDOOJfMm0F9\n" +
            "5Nmj+MmxAhoDZxVVWFLCVu+HHG2RbYcQXmp6ppB8k+x90+0mMiQYnda/Acx40wbD\n" +
            "mIJWfpBcknS2gZ8BUP1WCHsFQFA/bgAl55g5ELSNNSEWKXad4uRjRM/uqO172BPT\n" +
            "5q7bIOp6o6aWcp5/OdWhRbmDniwnJSPSF0x4Hh2g/wUvsEisMrjLnWGTDr1rjSay\n" +
            "k7YjB8lFb+1nitvs2lKPTcps3zqH/yO0wzrPuo7QfsXUOTyWJ48uHzw47hlD3r6j\n" +
            "a4qjS0eRIbm/JdHjWG8bXggcP0DEM4bjZLBgAxxoLN9dsO0ipL0LhKZPATk4CehD\n" +
            "f0+RQ3E6k7giIaG0HGFkYW0ucGlvdGVyZWtAcHJvdG9ubWFpbC5jb22JATIEEAEI\n" +
            "ACYFAlambngGCwkIBwMCCRAkQuJ3duCleAQVCAIKAxYCAQIbAwIeAQAAXn4H+wdp\n" +
            "P4d6fZQ4RNPw4RQXL3cy47Fzlv9b1MgYODzqKLvOATMPZfsfWJgoxMQoZw+omUmT\n" +
            "Zo3ZZZfTfbkd0Pteg7TNRS6h9a7G0JcufssAjwloiMgbu9aUzPZm3UFNVlSGWJ9a\n" +
            "Mx0kj70Rb9FHKpL7ZusaFqlrKL6UeU2K01qkNxIlhBJT8ba2poKicsgQw+CFrny9\n" +
            "+RgQZBc7jiqIEhJnbncKKXcRrXPJiZRmLnO+D19lWfztx0knf170t7qViLpQQKg9\n" +
            "H3jPvfn3bA55z6fNX/ye+HbVcVAvwUBv+XHMM34TKamQtm4n8QYXQHpNz8gpZj3F\n" +
            "60r5ZHbl9sbFVkshX06JAjMEEwEIAB0WIQR7+/lQaMiyBhaTPl00vtqh1iK4kQUC\n" +
            "WuJeXwAKCRA0vtqh1iK4kUOzEACF7ruZtvMzVCh77cqiyPf7QPJ03/tIEwuLj7I+\n" +
            "TgVTcvsllKfI1Rl8SlxPfvrs8yYzpy0M18fiMMepTv4TOXHZ4Q7QXf+lNzj4+LfY\n" +
            "4dQCkepdpUW3PjLuLzpbuLFKEketrXmeKpc4f9+WPsP8dh3e3BdfYmeFa0ZDP2bW\n" +
            "RfhxyB8gh5dptoJsClePBbe8c+Z5cmLRyQdAaKcMj7TymHO7Tdjix8M4yFOp6hyR\n" +
            "LuFDbcvciNIqsuePwT9U5y4hYbRzTrRMAEvKdX8UbDHY8SRI9G0L5mYYbKLb3IaC\n" +
            "2IMp23di8tmCxYts4Cjh40ItCFNdtDzgh3vuPpNni89Xp8OszTwUYZFvWIz1RWou\n" +
            "ZcehVPOugWtKyKn5RoN066OrJ4KBhjTMAir2+9GyBA/AN1GcfXMg30VfedZKS+Go\n" +
            "Cz74fQwH7VAJhYZxz42xdG+ilqB9b8qBY3uSoaoWwjZSuOisU4y4DVzuSjPNxDMB\n" +
            "HgSInb0JGeLvYKaD236nXYEDkptsqF+L4AT+szuDuMJeAWWyjfu8tz9TYcTu3rT+\n" +
            "QOfyc4iiz38t0MUUcJjWDlAfxt03+OHmSz1umXmEuaJbvGsfv6oylXC8vSGNpjdm\n" +
            "xgjg/+JYP8oDkx7h6t6ag4uEv7z/HFceMQ9YjDMTEd40lohcwRR6z9AHodrnlJsX\n" +
            "XaLEpLQrQWRhbSBQaW90ZXJlayA8YWRhbS5waW90ZXJla0Bwcm90b25tYWlsLmNo\n" +
            "PokBTgQTAQgAOBYhBJTz0F6hy365a6xPvyRC4nd24KV4BQJZZk/uAhsDBQsJCAcC\n" +
            "BhUICQoLAgQWAgMBAh4BAheAAAoJECRC4nd24KV4ANsH/jjwP1maFrFK/2LLDKO6\n" +
            "Gzp4Gn9fF0QhfQn6/4vv5packd5arLUyiCGrPVBlGGxEpkniv+lNf2ph3doSWGbg\n" +
            "3DiNVEpF05rMPBEOihlsE2AqgOsFJymVfYj/r3HibpkNyhKNSQ/WGHZZzMPdk/eA\n" +
            "aq0luvtHDzPMHStyQEZWmgChWFsjzY0XfZU3bok7bJrqOiNfDMAZsgsxSmn9zjPk\n" +
            "vihQvAywl7ilIunxmMy8T+b3By5MkHXKsQYdBLlB+jZPBebZHcSs6xJOlmM856Fs\n" +
            "etoP5XBz7+UuyPVqGp6a1O5Lg61DWnHwhSjlWVE4Fz2upzd2q70Ep1uFlhmsnIKm\n" +
            "0R+JAjMEEwEIAB0WIQR7+/lQaMiyBhaTPl00vtqh1iK4kQUCWuJeXwAKCRA0vtqh\n" +
            "1iK4kVxDD/9dFF9K4Lx8TRsZ7HpODaZskL2vGuJY9jhAWDlNIGTCddqGVDUXBEa6\n" +
            "pRG7OK0P+a2Ty/rH1pvKQWunWoiCOW2LTLT4y9eWwmKHj9f8Hak8V1sAuto7FWUB\n" +
            "btNr9+JYM6eyp7v/kyUreJ5DoSSLtgN1DSKtETi5oGhIxHmGPFlyhzv3XkkASAek\n" +
            "c53uk1H+KO464LtED4t1gb/o03G53V6A0wAte1BbopJsYgTXyKuMRmaFrE2Yxlb2\n" +
            "yC4rh8kUDJa0uIzmjD5qNgvcAFF1MIznOkeBsTmPUYBSypLvRRqq+38A+gYI7ZZt\n" +
            "N8GzTJAWNaia6BY3DW40mGxu7ziZsR3wyObdHquiOMonI9v1VDt+7OgrpBul/FGt\n" +
            "+HY9SDl4JeQeypQdWEbodQjfcIRPWezHOpxD1xsJP5xUTPPZaMiX4+gLY/CHliCq\n" +
            "7HzZ0OlRjvtRd493eibYfqQhsGwamZH00Qr8WujtyQyPg5M008RZingk8RMF7uWj\n" +
            "lKWe2Wf+CIYDCnWrK7wRWUI2GTu18Fv7UhN6AFtnqRU61rwjeWWmVWzcKq6zcUta\n" +
            "GllZLtVtfAFGAaNaiVPcQZ4eB9LWFe59gZm04tb6uevl5/V/Hz6mYJl06kq2pE7A\n" +
            "H2WrmEXPYGsC6IYaywfAq4smEdQPBJA82LuognpsiMnATaEWBgyhErkBDQRWpm53\n" +
            "AQgAs5ZKn4jgoZ45I9EGSaq1hIG7uF9gvGLi30o8oVMxY0pHAuSWrZEd/vStCl+1\n" +
            "/yM5Y9+pMxsuhFwE01BymaWGd2BGKg9zW1nFWxCfAck+f4Mh6tZblK1nJuNYOvcv\n" +
            "Ls7rY54jM/6ky/27GkQfS3zNDtJ+l9VByHj1qfbk3DDiJJhEjvacun701pW9eTK+\n" +
            "A1ZmPd8+3MiBUkdLu9mQcJzJt3RMnOjB+CYo22r3V5Xnq4Zs3na4uhSs95gkW8+G\n" +
            "fE4A8hn+TXFw+VxImyyHj1/fZDGD84Q5xarnEZbdoAy4/8gl5BO607/LAY3VycJL\n" +
            "+mRAjPzxJvBG+EoiVYY6dr5eUwARAQABiQEfBBgBCAATBQJY3pUiCRAkQuJ3duCl\n" +
            "eAIbDAAAJPcH/jpfkmzBg/MJKYKH02BhIm8ScEa5oB/8FjIbj5hg0stUFFA1TejW\n" +
            "noDNjnI4owcP3BMMLsC65c/94EZr040i3NCG9uyQfVtCO868RD8gP5Xk3xCCXm2o\n" +
            "ZbT8i7VFT3NYYvwMCrym9mNT9fgA/CU878Gr2sXFrwl6p5X+/xASV9mxrVeU+sL5\n" +
            "xFpuuFRIzKAjSNtGu4+0Li+Z8WNUkpXdH+HptJSQApuc//9MNgj1YnxydDb5esjA\n" +
            "apC5zPnTQ/xsJl1yjTEtzbZjymOFDRLc395wxx8u0YkA6BPYlimbvubUgpQ//3Fb\n" +
            "+xmIIwWFaLqxGfv00z/VKZIr+W3FmVX5IhI=\n" +
            "=LPxI\n" +
            "-----END PGP PUBLIC KEY BLOCK-----\n";

            $('#fail').css('display', 'none');

            var options = {
                data: msg,
                publicKeys: openpgp.key.readArmored(publicKeyString).keys
            };

            openpgp.encrypt(options).then(function(ciphertext) {
                $('#message').val(ciphertext.data);
                $('#reply-to').val('');
                $.ajax({
                    data: JSON.stringify({ email: ciphertext.data }),
                    contentType: "application/json; charset=utf-8",
                    method: "POST",
                    url: "/send.php",
                }).done(function(msg) {
                    setTimeout(function() {
                        $('#message').val('');
                        $('.sent').css('display', 'block');
                        $('.contact-form').css('display', 'none');
                    }, 1000);
                }).fail(function(msg) {
                    $('#fail').css('display', 'block');
                });
            });
        });
    });
// @license-end
</script>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt GNU-AGPL-v3.0
    $(function() {
        $('.no-js').css('display', 'none');
        $('.contact-form').css('display', 'block');
        $('textarea').val('');
        $('input').val('');
    });
// @license-end
</script>
